import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsInt, Length, IsOptional, Min, Max } from 'class-validator';

export class CreateDictDataDto {
  @ApiProperty({
    description: '关联字典编码',
    example: 'gender',
    required: true
  })
  @IsNotEmpty({ message: '字典编码不能为空' })
  @IsString({ message: '字典编码必须是字符串类型' })
  @Length(2, 50, { message: '字典编码长度必须在2-50个字符之间' })
  dictCode: string;

  @ApiProperty({
    description: '字典项值',
    example: '1',
    required: true
  })
  @IsNotEmpty({ message: '字典项值不能为空' })
  @IsString({ message: '字典项值必须是字符串类型' })
  @Length(1, 50, { message: '字典项值长度必须在1-50个字符之间' })
  value: string;

  @ApiProperty({
    description: '字典项标签',
    example: '男',
    required: true
  })
  @IsNotEmpty({ message: '字典项标签不能为空' })
  @IsString({ message: '字典项标签必须是字符串类型' })
  @Length(1, 100, { message: '字典项标签长度必须在1-100个字符之间' })
  label: string;


  @ApiProperty({
    description: '标签类型，用于前端样式展示',
    example: 'primary',
    required: false
  })
  @IsOptional()
  @IsString({ message: '标签类型必须是字符串类型' })
  @Length(0, 50, { message: '标签类型长度不能超过50个字符' })
  tagType?: string;

  @ApiProperty({
    description: '状态(0:禁用;1:正常)',
    example: 1,
    required: false,
    default: 1
  })
  @IsOptional()
  @IsInt({ message: '状态必须是整数类型' })
  @Min(0, { message: '状态值最小为0' })
  @Max(1, { message: '状态值最大为1' })
  status?: number;

  @ApiProperty({
    description: '排序',
    example: 1,
    required: false,
    default: 0
  })
  @IsOptional()
  @IsInt({ message: '排序必须是整数类型' })
  @Min(0, { message: '排序值最小为0' })
  sort?: number;

  @ApiProperty({
    description: '备注',
    example: '男性选项',
    required: false
  })
  @IsOptional()
  @IsString({ message: '备注必须是字符串类型' })
  @Length(0, 255, { message: '备注长度不能超过255个字符' })
  remark?: string;

  @ApiProperty({
    description: '创建人ID',
    example: 1,
    required: false
  })
  @IsOptional()
  @IsInt({ message: '创建人ID必须是整数类型' })
  createBy?: number;
}